package com.supermate.supercut.app.utils;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.RandomUtil;
import com.supermate.init.util.DateUtil;

import java.util.Date;
import java.util.Objects;

public class SequenceHelper {

    /**
     * 根据原来的文件名生产新的文件名，保留扩展名
     * @param fileName
     * @return
     */
    public static String generateFileNameByTime(String fileName) {
        String newFileName = DateUtil.formatDate(new Date(),DateUtil.YMD_HMS).get()+"_"+ RandomUtil.randomNumbers(4);
        String extName = FileUtil.extName(fileName);
        if (Objects.nonNull(extName)) {
            newFileName = newFileName + "." + extName;
        }
        return newFileName;
    }
}
